﻿CREATE PROCEDURE [dbo].[AddActivity]
	@Model uniqueidentifier,
	@ActivityId uniqueidentifier,
	@Tags nvarchar(max),
	@Description nvarchar(max),
	@Category uniqueidentifier,
	@ResponsiblePerson uniqueidentifier,
	@Priority int,
	@Progress int,
	@Quality int,
	@IsCompleted bit,
	@StartDate datetime,
	@DueDate datetime,
	@Ended datetime,
	@IsTemplate bit,
	@IsHierarchical bit,
    @IsDeleted bit,
	@CreatedBy uniqueidentifier,
	@CreatedOn datetime,
    @LastChanged datetime,
	@LastChangedBy uniqueidentifier,

	@TimeStamp timestamp output

AS

	INSERT INTO Activity 

	(Model, ActivityId, Tags, [Description], Category, ResponsiblePerson,
	 [Priority], Progress, Quality, IsCompleted, StartDate, DueDate, Ended,
	 IsTemplate, IsHierarchical, IsDeleted, CreatedBy, CreatedOn, LastChanged, LastChangedBy)

	VALUES 

	(@Model, @ActivityId, @Tags, @Description, @Category, @ResponsiblePerson,
	 @Priority, @Progress, @Quality, @IsCompleted, @StartDate, @DueDate, @Ended,
	 @IsTemplate, @IsHierarchical, @IsDeleted, @CreatedBy, @CreatedOn, @LastChanged, @LastChangedBy)

	SELECT @TimeStamp = [TimeStamp]

	FROM Activity WHERE ActivityId=@ActivityId

RETURN 0